#pragma once
#include <string>
#include <vector>

#include "BondInfo.h"
#include "BondMarketStream.h"
#include "bondlib.h"
// ***************************************************************
//  QBSortVContainer   version:  1.0
//  -------------------------------------------------------------
//  author:	Tony.luo
//    date: 2015-07-01
//   brief: 公用函数
//  -------------------------------------------------------------
//  Copyright (C) 2016 - Sumscope All Rights Reserved
// ***************************************************************
//
// ***************************************************************

#define PRECISION1 0.1
#define PRECISION2 0.01
#define PRECISION3 0.001
#define PRECISION4 0.0001
#define PRECISION5 0.00001
#define PRECISION6 0.000001

struct CFETSQUOTE;

S_BONDLIB_EXPORT const char* GetBidEstPrice(const REPORT& report,
                                            const CBondInfo* pBond,
                                            const int nBondIndex,
                                            bool bIsCDCAuthValid);
S_BONDLIB_EXPORT const char* GetBidEstPrice(int nBondIndex,
                                            const std::string& sBrokerID,
                                            bool bIsCDCAuthValid);
S_BONDLIB_EXPORT const char* GetBidEstPrice(const CFETSQUOTE* report,
                                            const CBondInfo* pBond,
                                            const int nBondIndex,
                                            bool bIsCDCAuthValid);
S_BONDLIB_EXPORT const char* GetBidEstPriceBySettlement(
    int nBondIndex, const std::string& sBrokerID, bool bIsCDCAuthValid,
    BYTE btSettlement);
S_BONDLIB_EXPORT const char* GetBidEstPriceMixedBP(const BrokerKey& key,
                                                   bool bIsCDCAuthValid,
                                                   BYTE btPriceFilter);

S_BONDLIB_EXPORT const char* GetEstPriceOfr(const REPORT& report,
                                            const CBondInfo* pBond,
                                            const int nBondIndex,
                                            bool bIsCDCAuthValid);
S_BONDLIB_EXPORT const char* GetEstPriceOfr(int nBondIndex,
                                            const std::string& sBrokerID,
                                            bool bIsCDCAuthValid);
S_BONDLIB_EXPORT const char* GetEstPriceOfr(const CFETSQUOTE* report,
                                            const CBondInfo* pBond,
                                            const int nBondIndex,
                                            bool bIsCDCAuthValid);
S_BONDLIB_EXPORT const char* GetEstPriceOfrBySettlement(
    int nBondIndex, const std::string& sBrokerID, bool bIsCDCAuthValid,
    BYTE btSettlement);
S_BONDLIB_EXPORT const char* GetEstPriceOfrMixedBP(const BrokerKey& key,
                                                   bool bIsCDCAuthValid,
                                                   BYTE btPriceFilter);

S_BONDLIB_EXPORT const char* GetBidCsiPrice(const REPORT& report,
                                            const CBondInfo* pBond);
S_BONDLIB_EXPORT const char* GetBidCsiPrice(int nBondIndex,
                                            const std::string& sBrokerID);
S_BONDLIB_EXPORT const char* GetBidCsiPrice(const CFETSQUOTE* report,
                                            const CBondInfo* pBond);
S_BONDLIB_EXPORT const char* GetBidCsiPriceBySettlement(
    int nBondIndex, const std::string& sBrokerID, BYTE btSettlement);
S_BONDLIB_EXPORT const char* GetBidCsiPriceMixedBP(const BrokerKey& key,
                                                   BYTE btPriceFilter);

S_BONDLIB_EXPORT const char* GetCsiPriceOfr(const REPORT& report,
                                            const CBondInfo* pBond);
S_BONDLIB_EXPORT const char* GetCsiPriceOfr(int nBondIndex,
                                            const std::string& sBrokerID);
S_BONDLIB_EXPORT const char* GetCsiPriceOfr(const CFETSQUOTE* report,
                                            const CBondInfo* pBond);
S_BONDLIB_EXPORT const char* GetCsiPriceOfrBySettlement(
    int nBondIndex, const std::string& sBrokerID, BYTE btSettlement);
S_BONDLIB_EXPORT const char* GetCsiPriceOfrMixedBP(const BrokerKey& key,
                                                   BYTE btPriceFilter);

S_BONDLIB_EXPORT const char* GetCsi_CdcPrice(
    const CBondInfo* pBond, const int nBondIndex,
    bool bIsCDCAuthValid);  // 中证-中债
S_BONDLIB_EXPORT const char* GetCsi_CdcPrice(
    int nBondIndex, bool bIsCDCAuthValid);  // 中证-中债

S_BONDLIB_EXPORT const char* GetCleanPriceDiv(
    const char* lpszTknCleanPrice,
    const char* lpszCdcCleanPrice);  // 净价偏离度
S_BONDLIB_EXPORT const char* GetYieldDiv(
    const char* lpszCdcVal, const char* lpszTknYield);  // 收益率偏离度

S_BONDLIB_EXPORT bool GetMarketStreamInfo(
    const CBondInfo* pBond, const char* lpszBrokerID,
    std::vector<MarketStreamInfo>* pStream, MarketStreamInfo& streamInfo);

// 浮点数比较函数
S_BONDLIB_EXPORT bool IsEqual(double dVal1, double dVal2);
S_BONDLIB_EXPORT bool IsLess(double dVal1, double dVal2);
S_BONDLIB_EXPORT bool IsLessAndEqual(double dVal1, double dVal2);
S_BONDLIB_EXPORT bool IsGreater(double dVal1, double dVal2);
S_BONDLIB_EXPORT bool IsGreaterAndEqual(double dVal1, double dVal2);

std::string S_BONDLIB_EXPORT GetBidEstPrice(const char* pBidPrice,
                                            const CBondInfo* pBond,
                                            const int nBondIndex,
                                            bool bIsCDCAuthValid);
std::string S_BONDLIB_EXPORT GetEstPriceOfr(const char* pOfrPrice,
                                            const CBondInfo* pBond,
                                            const int nBondIndex,
                                            bool bIsCDCAuthValid);
